package cos.parser;

import java.io.InputStreamReader;
import java.net.URL;

public class ParserUtils {
	/**
	 * Method read a page (by its URL) and returns its source
	 */
	public static String readUrlBytes(String address) {
		try {
			InputStreamReader isr = new InputStreamReader(
					new URL(address).openStream(), "UTF-8");
			StringBuilder sb = new StringBuilder();
			int c;
			while ((c = isr.read()) != -1) {
				sb.append((char) c);
			}
			isr.close();

			return sb.toString();

		} catch (Exception e) {
			return null;
		}
	}
}
